<?php

/**
 * This is the model class for table "{{importrule}}".
 *
 * The followings are the available columns in table '{{importrule}}':
 * @property double $id
 * @property string $code
 * @property string $name
 * @property string $tablename
 * @property double $mode
 * @property double $row
 * @property string $show
 * @property string $tablerow
 * @property string $stencil
 * @property double $status
 * @property string $remark
 * @property double $add_time
 */
class Importrule extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Importrule the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{importrule}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('mode, row, status, add_time', 'numerical'),
			array('code, tablename, show, tablerow', 'length', 'max'=>20),
			array('name, stencil', 'length', 'max'=>100),
			array('remark', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, code, name, tablename, mode, row, show, tablerow, stencil, status, remark, add_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'code' => 'Code',
			'name' => 'Name',
			'tablename' => 'Tablename',
			'mode' => 'Mode',
			'row' => 'Row',
			'show' => 'Show',
			'tablerow' => 'Tablerow',
			'stencil' => 'Stencil',
			'status' => 'Status',
			'remark' => 'Remark',
			'add_time' => 'Add Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('code',$this->code,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('tablename',$this->tablename,true);
		$criteria->compare('mode',$this->mode);
		$criteria->compare('row',$this->row);
		$criteria->compare('show',$this->show,true);
		$criteria->compare('tablerow',$this->tablerow,true);
		$criteria->compare('stencil',$this->stencil,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('add_time',$this->add_time);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}